//
// Created by Semir on 2020/6/1.
//

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int numDecodings(string s) {
    if (s.length() == 0 || s[0] == '0') {
        return 0;
    }
    int preNum = 1;
    int curNum = 1;
    int pre = s[0] - '0';
    int i = 1;
    int cur;
    while (i < s.length()) {
        cur  = s[i] - '0';
        if (cur == 0) {
            if (pre == 1 || pre == 2) {
                curNum = preNum;
            } else {
                return 0;
            }
        } else if ((cur < 7 && pre == 2) ||  pre == 1) {
            int tmp = preNum;
            preNum = curNum;
            curNum = tmp + curNum ;
        } else {
            preNum = curNum;
        }
        pre = cur;
        i++;
    }
    return curNum;
}

int main() {
    string str = "27";
    int res = numDecodings(str);
    cout << res << endl;
    return 0;
}